package org.hospital.service;

import java.sql.Timestamp;
import java.util.List;

import org.hospital.entity.Bill;
import org.hospital.entity.Clinic;
import org.hospital.entity.Department;
import org.hospital.entity.Project;

import com.alibaba.fastjson.JSONArray;

public interface BillService {

	/**
	 * 获取持久化对象
	 * 
	 * @param billId
	 * @return
	 */
	Bill getById(int billId);

	/**
	 * merge 方法插入 数据库
	 * 
	 * @param entity
	 * @return
	 */
	Bill addEntity(Bill entity);

	/**
	 * merge 方法插入 数据库
	 * 
	 * @param entity
	 * @return
	 */
	Bill saveEntity(Bill entity);

	/**
	 * 治疗单据录入(单据项目表;诊疗卡表;病例表)
	 * @param entity
	 * @param projects [{projectId:xx,number:xx,deadline:xx,extraInfo:xx}]
	 * @param clientId
	 * @param startTime  //单据开单时间
	 * @param diseaseName  //诊断疾病名称
	 * @return 插入数据库后bill对象
	 */
	Bill addTreatBill(Bill entity, JSONArray projects, int clientId,long startTime,String diseaseName);
	
	/**
	 * 费用单据录入(单据项目表)
	 * @param entity
	 * @param projects [{markText:xxx(摘要),projectId:xxx,costType:xxx,price:xxx}]
	 * @return 插入数据库后bill对象
	 */
	Bill addFundBill(Bill entity,JSONArray projects);
	/**
	 * 获取科室治疗项目报表条目数据
	 * 
	 * @param pjList
	 * @param department
	 * @param startTime
	 * @param endTime
	 * @return [{clinicId,clinicName,departmentId,departmentName,
	 *         projectId,projectName
	 *         ,sumIncome,sumSelfCost,sumOtherCost,sumProfit}]
	 */
	JSONArray getDepartmentTreatmentProjectReport(List<Project> pjList, Department department,
			long startTime, long endTime);

	/**
	 * 获取科室治疗项目自身支出细节(医生抽成、执行者抽成) 工号、类别、名字、次数、支出
	 * 
	 * @param pj
	 * @param department
	 * @param startTime
	 * @param endTime
	 * @return [{employeeId,employeeCode,type,name,number,costPrice}]
	 *         编号、工号、类别、名字、次数、支出;type: 医生(0),执行者(1)
	 * 
	 */
	JSONArray getDepartmentSelfCostDetail(Project pj, Department department, long startTime,
			long endTime);

	/**
	 * 获取科室治疗项目分院支出细节 门诊编号、门诊名、门诊支出、执行者编号、执行者工号、执行者名、执行者支出、治疗次数、总支出
	 * 
	 * @param pj
	 * @param clinic
	 * @param startTime
	 * @param endTime
	 * @return 
	 *         [{clinicId,clinicName,clinicCost,employeeId,employeeCode,employeeName
	 *         ,employeeCost,number,totalCost}]
	 */
	JSONArray getDepartmentOtherCostDetail(Project pj, Department dpm, long startTime, long endTime);

	/**
	 * 获取科室治疗项目医生开单汇总
	 * 
	 * @param pj
	 * @param clinic
	 * @param startTime
	 * @param endTime
	 * @return 
	 *         [{departmentId,departmentName,doctorId,doctorCode,doctorName,price
	 *         ,billNumber}]
	 */
	JSONArray getDepartmentTreatmentDetail(Project pj, Department dpm, long startTime, long endTime);

	/**
	 * 获取门诊治疗项目报表条目数据
	 * 
	 * @param pjList
	 * @param clinic
	 * @param startTime
	 * @param endTime
	 * @return 
	 *         [{clinicId,clinicName,projectId,projectName,sumIncome,sumSelfCost,
	 *         sumOtherCost ,sumProfit},{}]
	 */
	JSONArray getClinicTreatmentProjectReport(List<Project> pjList, Clinic clinic, long startTime,
			long endTime);

	/**
	 * 获取门诊治疗项目自身支出细节(医生抽成、执行者抽成) 工号、类别、名字、次数、支出
	 * 
	 * @param pj
	 * @param clinic
	 * @param startTime
	 * @param endTime
	 * @return [{employeeId,employeeCode,type,name,number,costPrice}]
	 *         编号、工号、类别、名字、次数、支出;type: 医生(0),执行者(1)
	 * 
	 */
	JSONArray getClinicSelfCostDetail(Project pj, Clinic clinic, long startTime, long endTime);

	/**
	 * 获取门诊治疗项目分院支出细节 门诊编号、门诊名、门诊支出、执行者编号、执行者工号、执行者名、执行者支出、治疗次数、总支出
	 * 
	 * @param pj
	 * @param clinic
	 * @param startTime
	 * @param endTime
	 * @return 
	 *         [{clinicId,clinicName,clinicCost,employeeId,employeeCode,employeeName
	 *         ,employeeCost,number,totalCost}]
	 */
	JSONArray getClinicOtherCostDetail(Project pj, Clinic clinic, long startTime, long endTime);

	/**
	 * 获取门诊治疗项目医生开单汇总
	 * 
	 * @param pj
	 * @param clinic
	 * @param startTime
	 * @param endTime
	 * @return 
	 *         [{clinicId,clinicName,departmentId,departmentName,doctorId,doctorCode
	 *         ,doctorName,price,billNumber}]
	 */
	JSONArray getClinicTreatmentDetail(Project pj, Clinic clinic, long startTime, long endTime);

	/**
	 * 获取门诊费用项目总报表
	 * 
	 * @param clinic
	 * @param startTime
	 * @param endTime
	 * @return [clinicId,clinicName,projectId,projectName,type,price]
	 */
	JSONArray getClinicFundProjectReport(Clinic clinic, long startTime, long endTime);

	/**
	 * 获取门诊费用项目细节报表
	 * 
	 * @param clinic
	 * @param projectId
	 * @param startTime
	 * @param endTime
	 * @return [operatorId,operatorCode,operatorName,price,dateTime]
	 */
	JSONArray getClinicFundProjectDetail(Clinic clinic, int projectId, long startTime, long endTime);
	
	Bill getClinicFirstBill(Clinic clinic);
	
	/**
	 *查看单据表
	 *
	 * @param date1
	 * @param date2
	 * @param category
	 */
	JSONArray getBill(Timestamp date1,Timestamp date2,String category);
}
